﻿using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace Luna.UI.Wpf
{
    [ValueConversion(typeof(string), typeof(ImageSource))]
    public class ConnectorStateConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                bool L_Value = (bool)value;
                Uri L_FilePath;

                if (L_Value)
                {
                    L_FilePath = new Uri("pack://application:,,,/Luna;component/Resources/connector_enabled.png");
                }
                else
                {
                    L_FilePath = new Uri("pack://application:,,,/Luna;component/Resources/connector_disabled.png");
                }

                return BitmapFrame.Create(L_FilePath);
            }
            catch
            {
                return DependencyProperty.UnsetValue;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
